studentScoreList = function(){
	
	Ext.define('studentScore',{
		extend:'Ext.data.Model',
		fields:[ 	
		        	{name:'id',type:'String'},
		        	{name:'studentId',type:'String'},
		        	{name:'studentName',type:'string'},
		        	{name:'courseName',type:'string'},
		        	{name:'credit',type:'String'},
			        {name:'testScores',type:'string'},
			        {name:'peacetimeScores',type:'string'},
			        {name:'prom',type:'string'},
			        {name:'grade',type:'string'},
			        {name:'hourse',type:'string'},
			        {name:'isAgain',type:'string'},
			        {name:'scores',type:'string'}
			       ],
		idProperty : 'id'
	});
	

	var store = Ext.create('Ext.data.Store',{
		pageSize:100,
		model:studentScore,
		autoLoad:true,
		proxy:{
			type:'ajax',
			url:'searchStudentScoresListAction.action',
			reader:{
				type:'json',
				root:'resultList.list',
				totalProperty:'resultList.total'
			}
		}
	});
	
	//学号
	var CstudentId ={
			width: 200,
			xtype: 'textfield',
			id: 'SstudentId',
			labelWidth:60,
			fieldLabel: '学号'	
		}
	//姓名
	var CstudentName ={
			width: 200,
			xtype: 'textfield',
			id: 'SstudentName',
			labelWidth:60,
			fieldLabel: '姓名'	
		}
	//年级
	gradeS = getStaticDataStore("grade");
	var Cgrade = new Ext.form.ComboBox({
        fieldLabel: '年级',width: 200,
        store: gradeS,
        displayField: 'valueName',
        valueField: 'valueId',
        triggerAction: 'all',
        labelWidth:60,
        id:'Sgrade'
       	 });
	//学年
	promS = getStaticDataStore("prom");
	var Cprom = new Ext.form.ComboBox({
        fieldLabel: '学年',
        store: promS,
        displayField: 'valueName',
        valueField: 'valueName',
        triggerAction: 'all',
        labelWidth:60,
        id:'Sprom'
       	 });
	//课程名称
	var courseName ={
			width: 200,
			xtype: 'textfield',
			id: 'courseName',
			labelWidth:60,
			fieldLabel: '课程名称'	
		}
	var rowmn = {
		       //columnWidth: .30,
		       // height:150,
		        layout: 'column',
		        xtype:'panel',
		        border:false,
		       // style:'margin-left:50px;margin-top:50px',
		       /* fieldDefaults: {
			        labelWidth:40,
			        anchor: '100%'
			    },*/
		        items: [
						CstudentId,
						CstudentName,
						Cgrade,
						Cprom,
						courseName
		                ]
			};
	var Scondiction = Ext.create('Ext.FormPanel', {
	    title: '查询条件',
	    layout: 'form',
	    frame: true,
	   
	    width: '100%',
	    id:"Scondition",
	   // renderTo:'form-ct',
	    bodyPadding: 10,
	    items: [
rowmn
	    ],
	    buttons: [{
	        text: '查询',
	        handler: function(){
	        	var studentId =  Ext.getCmp('SstudentId').getValue();
	        	var studentName =  Ext.getCmp('SstudentName').getValue();
	        	var grade =  Ext.getCmp('Sgrade').getValue();
	        	var prom =  Ext.getCmp('Sprom').getValue();
	        	var courseName = Ext.getCmp('courseName').getValue();
	        	//var str = "role:"+role;
	        	store.load({
	        		
      		      params:{
      		    	  page:0,
      		    	  limit:0,
      		    	  studentId:studentId,
	      		    studentName:studentName,
	      		    grade:grade,
	      		    prom:prom,
	      		    	courseName:courseName
      		      },   //参数
      		           // callback是加载完毕时执行的回调函数，它包含3个参数：records参数表示获得的数据，
      		         // options表示执行load()时传递的参数，success表示是否加载成功。
      		      callback: function(records, options, success){
      		                 //Ext.Msg.alert('info', '加载完毕');
      		        },
      		       scope: store,       //Scope用来指定回调函数执行时的作用域
      		       add: false             //Add为true时，load()得到的数据会添加在原来的store数据的末尾，
      		                                    //否则会先清除之前的数据，再将得到的数据添加到store中
	        	});
	        }
	    },{
	        text: '重置',
	        handler: function(){
	           // fp.getForm().reset();
	        	Ext.getCmp('Scondition').form.reset();
	        }
	    }],
	    buttonAlign : "center"
	});
	
	var checkBox = Ext.create('Ext.selection.CheckboxModel');
	
	var grid = Ext.create('Ext.grid.Panel',{
		store:store,	
		columnLines:true,
		selModel:checkBox,
		disableSelection:false,
		//width:600,
		id:"grid11",
		loadMask:true,
		plugins:[  
	             Ext.create('Ext.grid.plugin.RowEditing',{
	            	// pluginId:'newEdit',
	            	 saveBtnText: '确定', 
	                 cancelBtnText: "取消"
	             })  
	    ],
		columns:[
		         //{text:'编号',width:100,dataIndex:'id',sortable:true},
		         {text:'学号',width:100,dataIndex:'studentId',sortable:true,editor:{allowBlank : false}},
		         {text:'姓名',width:100,dataIndex:'studentName',sortable:true,editor:{allowBlank : false}},
		         {text:'年级',width:60,dataIndex:'grade',sortable:true,editor:{
	  			    	xtype:'combobox',
	 			    	alias:'widget.lifechannelCombo',
	 			        width: 60,
	 			        store: gradeS,
	 			        displayField: 'valueName',
	 			        valueField: 'valueName',
	 			        triggerAction: 'all',
	 			        queryMode:'local', 
	 			        allowBlank : false
	        		 },renderer:function(v){
	        			 var index = gradeS.find('valueId',v); 
	        			 if(index != -1){
	        				 var r = gradeS.getAt(index);
	        				 return r.get("valueName");
	        			 }
	        			 else{
	        				 return v;
	        			 }
	        		 }},
		         {text:"学年",width:160,dataIndex:'prom',sortable:true,editor:{
	  			    	xtype:'combobox',
	 			    	alias:'widget.lifechannelCombo',
	 			        width: 160,
	 			        store: promS,
	 			        displayField: 'valueName',
	 			        valueField: 'valueName',
	 			        triggerAction: 'all',
	 			        queryMode:'local', 
	 			        allowBlank : false
	        		 },renderer:function(v){
	        			 var index = promS.find('valueId',v); 
	        			 if(index != -1){
	        				 var r = promS.getAt(index);
	        				 return r.get("valueName");
	        			 }
	        			 else{
	        				 return v;
	        			 }
	        		 }},
		         {text:'课程名称',width:150,dataIndex:'courseName',sortable:true,editor:{allowBlank : false}},
		         {text:'学时',width:50,dataIndex:'hourse',sortable:true,editor:{allowBlank : false}},
		         {text:'学分',width:50,dataIndex:'credit',sortable:true,editor:{allowBlank : false}},
		         {text:'平时成绩',width:60,dataIndex:'peacetimeScores',sortable:true,editor:{allowBlank : false}},
		         {text:'考试成绩',width:60,dataIndex:'testScores',sortable:true,editor:{allowBlank : false}},
		         {text:'分数',width:50,dataIndex:'scores',sortable:true,editor:{allowBlank : false}},
		         {text:'是否补考',width:60,dataIndex:'isAgain',sortable:true,renderer:function(v){
        			 if(v == "1"){
        				 return '<span style="color:#aa0000">是</span>';
        			 } else{
        				 return "";
        			 }
        			}
        		}
		         ],
		autoHeight:true,
		authWidth:true,

		title:"学生成绩列表",
		loadMask:true,
		pageSize:5,
		dockedItems:[{
			dock:'top',
			xtype:'toolbar',
			//height:200,
			items:[{
				width:300,
				fieldLabel:'搜索',
				labelWidth:70,
				xtype:'searchfield',
				store:store			
			},{
				xtype:'label',
				html:'<div style="font-size:12px;color:red">*支持姓名和学号的模糊查询</div>'
			},'->',{
				text:'Excel导入',
				iconCls:'applicationOsxGet',
				xtype:'button',
				handler:function(){
					var importStudentScoreWindow = Ext.create('Ext.Window',{
						layout:'fit',
						width:400,
						height:200,
						closeAction:'hide',
						plain:true,
						resizable : false,
						title:'excel导入',
						items:importStudentScoreForm,
						plain:true
						
					});
					importStudentScoreWindow.show();
				}
			},'-',{
				text:'删除',
				iconCls:'Decline',
				xtype:'button',
				handler:otherDelete
			},'-',
			{
				text:'提交数据',
				iconCls:'Applicationform',
				xtype:'button',
				handler:alter
			}]		
		},
		{
			dock:'bottom',
			xtype:'pagingtoolbar',	
			store:store,
			displayInfo:true,
			displayMsg:'显示{0}-{1}条，共计{2}条',
			emptyMsg:"没有数据"
		},{
			dock:'bottom',
			xtype:'label',
			html:'<div style="font-size:12px;color:red">1.双击进行单行编辑&nbsp&nbsp2.修改后需要提交数据进行保存</div>'
		},{
            xtype: 'panel',
            dock: 'bottom',
            items: [
                Ext.create('Ext.ux.exporter.Button', {
                    component: Ext.getCmp('grid'),
                    text: "导出 Excel"
                })
            ]
        }]
	});
	
	var panel = Ext.create('Ext.panel.Panel',{
		//enableTabScroll: true,
		width:'100%',
		height:400,
		autoScroll : true,
		//x:100,
		//layout: 'column',
       // layout: 'border',
		//margin:'2 10 3 10',
		//title:"kkkkkk",
		region:'center',
		/*layout: {
		    type: 'hbox',
		    align: 'middle ',
		    pack: 'center'
		},*/
		/*layout:{    
			align: 'center',
            type:'table',//表格布局    
            columns:2 //设置表格布局默认列数为2列    
        },*/ 
       items: [Scondiction,grid],
        listeners: {
            'afterrender': function () {
         	  // Ext.Msg.alert("ss",store.first().get('studentId'));           	
            }
        }
	});
	function otherDelete(){
		var data = grid.getSelectionModel().getSelection();  
	    if (data.length == 0) {  
	        Ext.Msg.alert("提示","请先选择要操作的行");  
	        return;  
	    } else {  
	        Ext.Msg.confirm("请确认", "是否真的要删除数据？", function(button, text) {  
	            if (button == "yes") {  
	                var ids = [];  
	                Ext.Array.each(data, function(record) {  
	                            var id=record.get('id');  
	                            //如果删除的是幻影数据，则id就不传递到后台了，直接在前台删除即可  
	                            if(id){  
	                            	ids.push(id);  
	                            } 
	                            else{
	                            	store.remove(record);
	                            }
	                        });
	                //Ext.Msg.alert(teacherIds);
	                if(ids.length==0){return;}
	                Ext.Ajax.request({  
	                    url : 'deleteStudentScoreAction.action',  
	                    params : {  
	                    	ids : ids.join(',')  
	                    },  
	                    method : 'POST',  
	                    success : function(response, opts) {  
	                        var success = Ext.decode(response.responseText).success;  
	                        // 当后台数据同步成功时  
	                        if (success) {  
	                           /* Ext.Array.each(data, function(record) {  
	                                        store.remove(record);// 页面效果  
	                                    });  */
	                        	Ext.Msg.alert("提示","删除成功！");
	                        	store.load();
	                        } else {  
	                        	Ext.Msg.alert("提示","删除失败！");
	                        }  
	                    }  
	                });  
	            }  
	        });  
	    }  
	}
	function alter() { 
	    var records = store.getUpdatedRecords();// 获取修改的行的数据，无法获取幻影数据  
	    var phantoms=store.getNewRecords( ) ;//获得幻影行  
	    records=records.concat(phantoms);//将幻影数据与真实数据合并  
	    if (records.length == 0) {  
	    	Ext.Msg.alert("提示","没有数据需要提交");   
	        return;  
	    } else {  
	        Ext.Msg.confirm("请确认", "是否真的要修改数据？", function(button, text) {  
	            if (button == "yes") {  
	                var data = [];  
	                Ext.Array.each(records, function(record) {
	                	//Ext.Msg.alert(record.data.teacherName);
	                    data.push(record.data);  
	                    });
	                Ext.Ajax.request({  
	                    url : 'updateStudentScoresAction.action',  
	                    params : {  
	                    	studentScoreListStr : Ext.encode(data)  
	                    },  
	                    method : 'POST',  
	                    success : function(response, opts) {  
	                        var success = Ext.decode(response.responseText).success;  
	                        // 当后台数据同步成功时  
	                        if (success) {  
	                        	store.load();
	                            Ext.Msg.alert("提示","提交成功");
	                        } else {  
	                            Ext.Msg.alert("提示",Ext.decode(response.responseText).msg); 
	                        }  
	                    }  
	                });  
	            }  
	        });  
	    }  
	}
	var importStudentScoreForm=new Ext.FormPanel({ 
		title:'上传新文件',
	   // id:'uploadForm', 
	   // anchor:'100%',	    
	    frame:true, 
	    fileUpload: true,   
	    autoHeight:true, 
	    //labelWidth:50, 
	    enctype: 'multipart/form-data',  
	    defaults:{ 
	        anchor: '90%', 
	        allowBlank: false 
	    }, 
	    items:[ 
	        { 
	            xtype:'fileuploadfield', 
	            emptyText: '请选择上传文件...',  
	            fieldLabel: '文件',  
	           // id:'uploadFile', 
	            name: 'file',  
	            allowBlank: false,    
	            blankText: '文件名称不能为空.',    
	            buttonConfig: { 
	                        text: '选择...'
	              } 
	        } 
	    ], 
	    buttons: [{ 
	                    text: '上传', 
	                    handler: function(){ 
	                        if(importStudentScoreForm.getForm().isValid()){ 
	                        	importStudentScoreForm.getForm().submit({ 
	                                url:'insertSelectiveStudentScoreAction.action', 
	                                method:'POST', 
	                                waitTitle: '请稍后', 
	                                waitMsg: '正在上传文档文件 ...', 
	                                success: function(fp, action){ 
	                                	//if(action.)
	                                    Ext.MessageBox.alert('信息', action.result.msg);   
	                                  //  importTeacherForm.getForm().reset();         // 指定文件字段的id清空其内容  
	                                    store.load(); 
	                                }, 
	                                failure: function(fp, action){ 
	                                    Ext.MessageBox.alert('警告', action.result.msg);   
	                                } 
	                            }); 
	                        } 
	                    } 
	                },{ 
	                    text: '重置', 
	                    handler: function(){ 
	                    	importStudentScoreForm.getForm().reset(); 
	                    } 
	                }],
	    buttonAlign:'center'
	       
	});
	return panel;
}